#if !defined(ALLOCHIERARCHY_H)
#define ALLOCHIERARCHY_H

#include <d3dx9.h>

struct TMeshContainer;

/*! \class CAllocHierarchy
	\brief Responsible for allocating mesh hierarchies. */
class CAllocHierarchy : public ID3DXAllocateHierarchy
{
public:
	STDMETHOD	(CreateFrame)			(LPCSTR Name, LPD3DXFRAME *ppFrame);
	STDMETHOD	(CreateMeshContainer)	(LPCSTR Name,
										CONST D3DXMESHDATA *pMeshData, 
										CONST D3DXMATERIAL *pMaterials, 
										CONST D3DXEFFECTINSTANCE *pEffectInstances, 
										DWORD NumMaterials, 
										CONST DWORD *pAdjacency, 
										LPD3DXSKININFO pSkinInfo, 
										LPD3DXMESHCONTAINER *ppNewMeshContainer);
	STDMETHOD	(DestroyFrame)			(LPD3DXFRAME pFrameToFree);
	STDMETHOD	(DestroyMeshContainer)	(LPD3DXMESHCONTAINER pMeshContainerToFree);

	IDirect3DDevice9	*m_pDevice;

private:
	void	ConvertToIndexedBlendedMesh	(TMeshContainer *pMeshContainer);
	void	CopyName					(char **ppName, const char *pName);
	void	CreateTextures				(const D3DXMATERIAL *pMaterial, D3DXMESHCONTAINER *pMeshContainer);
	void	GetAABoundingBox			(TMeshContainer *pMeshContainer);
};

#endif // ALLOCHIERARCHY_H